//
//  CXHomeListModel.swift
//  CXSwiftDemo
//
//  Created by 潮汐 on 2023/11/28.
//  Copyright © 2023 小潮汐. All rights reserved.
//
//cell上的数据模型
import KakaJSON

//嵌套的数据
struct User: Convertible {
    let thumb:String = ""
    let medium:String = ""
    let age:Int = 0
    let id:String = ""
    let name:String = ""//对应后台字段login
    
    //替换服务器返回的字段名，自己新起一个名字
    func kj_modelKey(from property:Property) -> ModelPropertyKey {
        if property.name == "name" {//name是自定模型里定义的名字
            return "login"//对应的服务器名字
        }
        return property.name
    }
}

//主模型数据
struct CXHomeListModel: Convertible {
    let name:String = ""//对应后台字段login
    let content:String = ""
    let age:Int = 0
    let thumb:String = ""
    let medium:String = ""
    let id:String = ""
    let user:User! = nil
    
    //替换服务器返回的字段名，自己新起一个名字
    func kj_modelKey(from property:Property) -> ModelPropertyKey {
        if property.name == "name" {
            return "login"//对应的服务器名字
        }
        return property.name
    }
}
